<template>
	<view class="content">

		<view style="margin: 0 auto; text-align: center;  border-radius: 80rpx;">
			<view style="width: 150rpx; margin: 0 auto; padding-top: 120rpx;">
				<image class="gui-list-image ucenter-face-image"
					src="http://boyaltd.oss-cn-hangzhou.aliyuncs.com/2022-09/30/URYwmphpTzYSFy1664527982220930.png"
					mode="widthFix"></image>
			</view>
			<view class="gui-list-items">
				<view class="gui-list-body gui-color-white" @tap="to_my_detail">
					<view>
						<text class="gui-list-title-text"
							style="font-size: 42rpx;">{{user.chinaname}}</text>
					</view>
					<text class="gui-list-body-desc gui-block-text" style="font-size: 32rpx;">手机号:{{user.phone}}</text>
					<!-- <text class="gui-list-title-text gui-block-text" style="font-size: 32rpx;">漂流币 : {{user.drift == null ? "0" : user.drift}}</text> -->
					<text class="gui-list-title-text gui-block-text"
						style="font-size: 32rpx; margin-left: -33rpx;">组织:{{user.organization == null ? "无" : user.organization}}</text>
					<!-- <button @tap="to_my_drift_log" class="gui-bg-blue" style="width: 300rpx;color: white;margin-top: 20rpx;">漂流币明细</button> -->
				</view>
			</view>
		</view>

		<view style="margin-top: 228rpx; font-size: 28rpx;">
			<view style="width: 90%; margin: 0 auto; border-radius: 20rpx; font-size: 32rpx; margin-bottom: 20rpx;">
				医疗互助计划退出:
			</view>
			<view class="crosswise1">
				<view v-for="(item, idx) in mutualAssistanceQuit" @click="toClick(item.url)">
					<view style="width: 80rpx; height: 80rpx; margin: 0 auto;">
						<image style="width: 100%; height: 100%;" :src="item.picture" mode="widthFix">
						</image>
					</view>

					<view style="margin-top: 15rpx;">{{item.name}}</view>
				</view>
			</view>
		</view>

		<view style="margin-top: 20rpx; font-size: 32rpx;">
			<view class="crosswise2">
				<view v-for="(item, idx) in inCommonUse" @click="toClick(item.url)">
					<view style="display: flex; align-items: center;">
						<image style="width: 75rpx; height: 75rpx;" :src="item.picture" mode="widthFix">
						</image>
						<view style="margin-left: 15rpx;">{{item.name}}</view>
					</view>
					<image style="width: 40rpx; height: 40rpx;" src="@/static/activity/apply/my/you.png"
						mode="widthFix"></image>
				</view>
			</view>
		</view>

		<gui-popup ref="guimodal">
			<view>
				<image :src="user.hzj_img" mode="" mode="widthFix"></image>
				<!-- <image src="../../static/my/certificate.jpg" mode="" mode="widthFix"></image> -->
			</view>
		</gui-popup>

		<menuBar menu_index="1" />

	</view>
</template>
<script>
	import menuBar from '../index/menu_bar.vue';
	export default {
		components: {
			menuBar
		},
		data() {
			return {
				user: [],
				mutualAssistanceQuit: [{
						id: 1,
						name: '缴费记录',
						picture: '../../../../static/activity/apply/my/jiaofeijl.png',
						url: '../index/mutual_aid_money'
					},
					{
						id: 0,
						name: '互助计划退出',
						picture: '../../../../static/activity/apply/my/huzhutc.png',
						url: '../index/type?category=49&cate_name=医疗互助计划退出'
					},
					{
						id: 2,
						name: '缴费凭证',
						picture: '../../../../static/activity/apply/my/pingzheng.png',
						url: '../index/voucher'
					},
				],
				inCommonUse: [{
						id: 0,
						name: '审核申请单',
						picture: '../../../../static/activity/apply/my/shenhe.png',
						url: '../admin/index'
					},
					{
						id: 1,
						name: '我的申请单',
						picture: '../../../../static/activity/apply/my/shenqing.png',
						url: '../index/my_apply'
					},
					// {
					// 	id: 2,
					// 	name: '刷新信息',
					// 	picture: '../../../../static/activity/apply/my/shuaxin.png',
					// 	url: 'update_user'
					// },
					// {
					// 	id: 3,
					// 	name: '退出登录',
					// 	picture: '../../../../static/activity/apply/my/dengchu.png',
					// 	url: 'loginout'
					// },
				],
				shifou: null,
			}
		},
		onLoad() {
			this.user = uni.getStorageSync("member");
			console.log(this.user, 'user');

			if (!this.user) {
				uni.reLaunch({
					url: "../login/login"
				});
			} else {
				// this.update_user();
			}
			// this.getdata();
		},
		onReady() {
			// this.update_user();
			this.lishijilu();
		},
		methods: {
			lishijilu() {
				let self = this
				// 获取当前日期
				let today = new Date();
				// 获取年份
				let year = today.getFullYear();
				// 获取月份（注意月份是从0开始计数的，所以要加1）
				let month = today.getMonth() + 1;
				// 获取日期
				let day = today.getDate();
				let demo2Val = year + '/' + month + '/' + day
				console.log(demo2Val);

				let url = '/hzj/get_order'
				let parm = {
					name: self.user.chinaname,
					pages: 1,
					price: 0,
					limit: 10000,
					sele_fee: null,
					uuid: self.user.uuid,
					time: {
						star_time: '2018/01/01',
						end_time: demo2Val
					},
					// token: '14d78037-08e3-49bf-b4ec-b8da61979af1'
					token: uni.getStorageSync("ttsxAuthToken")
				}
				self.$boya.NPost(url, parm, function(res) {
					uni.hideLoading();
					console.log('res.data.hzj_sum: ', res);
					if (res.data.hzj_sum >= 10000) {
						self.shifou = '是'
					} else {
						self.shifou = '否'
					}
				})
			},
			toClick(url) {
				console.log('url: ', url);
				if (url == 'update_user') {
					this.update_user();
				} else if (url == 'loginout') {
					this.loginout();
				} else if (url == 'voucher') {
					// !this.user.hzj_img
					if (this.shifou != '是') {
						uni.showModal({
							title: '提示',
							showCancel: false,
							content: '医疗互助金未缴足，暂无缴费凭证',
							success: function(res) {
								if (res.confirm) {
									console.log('用户点击确定');
								}
							}
						});
					} else {
						uni.navigateTo({
							url: '/pages/apply/voucher'
						})
						// this.$refs.guimodal.open();
					}
				} else {
					uni.navigateTo({
						url: url
					})
				}
			},
			to_my_drift_log() {
				if (this.user) {
					uni.navigateTo({
						url: './my_drift_log'
					});
				} else {
					uni.showToast({
						title: '未检测到用户信息!!'
					});
				}
			},
			update_user() { //更新人员信息
				let self = this;
				let user_id = this.user.id;
				if (user_id) {
					if (self.user.type != 9) {
						uni.removeStorage({
							key: 'token',
							success: function(res) {
								console.log("退出登录");
							}
						});
						uni.removeStorage({
							key: 'user',
							success: function(res) {
								console.log("退出登录");
							}
						});


						let url = '/public/login'
						let parm = {
							phone: self.user.phone,
							password: '123456'
						}
						self.$boya.NPost(url, parm, function(res) {
							if (res.code == 200) {
								uni.setStorageSync("token", res.token);
								uni.setStorageSync("user", res.data);
								self.user = res.data;
								uni.showToast({
									title: '刷新成功 --- ' + res.data.name,
									icon: 'none'
								});
							} else {
								self.tip(0, '请自主重新登录!!' + res.msg);
							}
							console.log(res, '更新用户信息');
						})
					}
				} else {
					self.tip(0, '无用户信息!!');
				}
			},
			loginout() {
				uni.removeStorage({
					key: 'token',
					success: function(res) {
						console.log("退出登录");
					}
				});
				uni.removeStorage({
					key: 'user',
					success: function(res) {
						uni.reLaunch({
							url: "../login/login"
						});
					}
				});
			},
			to_my_rank() {
				uni.navigateTo({
					url: "./my_book",
				});
			},
			to_my_detail() {
				// uni.navigateTo({
				// 	url: "../my_detail/my_detail",
				// });
			},
			tip(code, text) {
				if (code == '0') {
					uni.showToast({
						icon: 'error',
						title: text
					});
				} else if (code == '1') {
					uni.showToast({
						icon: 'success',
						title: text
					});
				} else {
					uni.showToast({
						icon: 'loading',
						title: text
					});
				}
			}
		}
	}
</script>
<style>
	.content {
		width: 100vw;
		height: 100vh;
		background: url('http://boyaltd.oss-cn-hangzhou.aliyuncs.com/2022-08/08/Ef2UIphpKdlsKa1659930541220808.jpg') 100% 100% / 100% 100%;
	}

	.ucenter-face {
		width: 100rpx;
		height: 100rpx;
	}

	.ucenter-face-image {
		width: 150rpx;
		height: 150rpx;
	}

	.ucenter-line {
		height: 20rpx;
		/* background-color:#F6F7F8; */
		margin: 16rpx 0;
	}

	.logoff {
		line-height: 88rpx;
		font-size: 28rpx;
		color: #000000;
	}

	.gui-list-title-text {
		line-height: 60rpx;
	}

	.crosswise1 {
		width: 80%;
		margin: 0 auto;
		background-color: rgba(242, 243, 245, 0.7);
		border-radius: 40rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;
		padding: 30rpx 40rpx;
		padding-top: 35rpx;
	}

	.crosswise1>view {
		margin: 0 20rpx;
	}

	.crosswise2 {
		width: 85%;
		margin: 0 auto;
		/* background-color: rgba(255, 255, 255, 0.8); */
		border-radius: 40rpx;
		padding: 30rpx;
	}

	.crosswise2>view {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 10rpx 0;
		border-bottom: 1rpx solid #F9F9F9;
		padding: 10rpx 0;
	}
</style>